package pl.un4giv3n.mightvsmagic.action;

import javax.persistence.EntityManager;

import pl.un4giv3n.mightvsmagic.entity.User;
import pl.un4giv3n.mightvsmagic.utils.UserUtil;


/**
 * @author andrzejewskia 
 * go-to-register-jsp action
 */
public class PremiumPageAction extends PersistenceAction {

	private static final long serialVersionUID = 1L;
	private User user;

	
	@Override
	public String execute() {
		EntityManager entityManager = getEntityManager();
		user = getSessionUser(entityManager);
		if(user == null){
			addActionError("Zaloguj się");
			entityManager.close();
			return LOGIN;
		}
		return SUCCESS;
	}


	public User getUser() {
		return user;
	}
	
	public String getPremiumEndTimeInfo(){
		return UserUtil.getPremiumEndTimeInfo(user);
	}
	
}
